<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>文本内容操作</title>
    <script type="text/javascript"src="../js/jquery-3.3.1.js"></script>
    <script type="text/javascript">
      $(document).ready(function () {
          //给div赋上文本内容
          $("div").text("<h1 style='background:yellow'>hello</h1>");
          //获取文本内容
          var $text=$("span").text();
          alert($text);
      })
    </script>
</head>
<body>
      <div></div>
      <span style="background: coral">HLOmaster</span>
</body>
</html>